<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
	version="2.0">
	<xsl:template match="/">
		<xsl:variable name="allauthors">
			<authors>
				<xsl:for-each select="/books/book">
					<xsl:sort select="@author" />
					<author id="{@author}" />
				</xsl:for-each>
			</authors>
		</xsl:variable>
		<xsl:variable name="authors">
			<authors>
				<xsl:for-each select="$allauthors/authors/author">
					<xsl:if
						test="not(preceding-sibling::author/@id=./@id)">
						<xsl:copy-of select="." />
					</xsl:if>
				</xsl:for-each>
			</authors>
		</xsl:variable>
		<xsl:copy-of select="$authors" />
	</xsl:template>
</xsl:stylesheet>